<?php
class AddProjectForm extends Zend_Form
{
	public function init()
	{
		$pname = $this->createElement('text','pname');
		$pname->setLabel('* Name:')
				->setRequired(true);
				
		$pkey = $this->createElement('text','pkey');
		$pkey->setLabel('* Key:')
				->setRequired(true)
				->setDescription('<font size = "1"><br>This is the unique project key. The project key:
								<br>* should be short and descriptive, as it prefixes each issue in the project;
								<br>* should not contain sensitive information, as it may be visible to users who do not have permission to view the project;
								<br>* cannot be changed once the project is created.</font>');
										
		$url = $this->createElement('text','url');
		$url->setLabel('URL:')
				->setDescription('<font size = "1"><br>An optional URL associated with this project, eg. pointing to project documentation.</font>');
				
		$lead = $this->createElement('text','lead');
		$lead->setLabel('* Project Lead:')
				->setRequired(true)
				->setDescription('<font size = "1"><br>Start typing to get a list of possible matches.</font>');
				
		$description = $this->createElement('textarea','description');
		$description->setLabel('Description:')
					->setAttrib('rows',5)
					->setAttrib('cols',40)
					->setAttrib('style','width:90%')
					->setDescription('<font size = "1"><br>Optional description of this particular project.
									  <br>You can include HTML, but make sure to close all your tags.</font>');
									  
		$add = $this->createElement('submit','add');
		$add->setLabel('Add')
				->setDecorators(array(
							'viewHelper',
								'Errors',
								array('Description', array('tag'=>'', 'escape'=>false)),
								array(array('data'=>'HtmlTag'),
									array('tag'=>'td', 'valign'=>'top', 'style'=> 'background-color:#ffffff;text-align:center','openOnly'=>true,'colspan'=>2,'align'=>'center')),
								//array('Label', array('tag'=>'td')),
								array(array('row'=>'HtmlTag'), array('tag'=>'tr','openOnly'=>true))
				));
				
		$cancel = $this->createElement('button','cancel');
		$cancel->setLabel('Cancel')
				->setDecorators(array(
							'viewHelper',
								'Errors',
								array('Description', array('tag'=>'', 'escape'=>false)),
								array(array('data'=>'HtmlTag'),
									array('tag'=>'td', 'valign'=>'top', 'style'=> 'background-color:#ffffff','closeOnly'=>true)),
								//array('Label', array('tag'=>'td')),
								array(array('row'=>'HtmlTag'), array('tag'=>'tr','closeOnly'=>true))
				));
				
		$this->addElements(array(
					$pname,
					$pkey,
					$url,
					$lead,
					$description,
					$add,
					$cancel
		));
		
		$this->setElementDecorators(array(
								'viewHelper',
								'Errors',
								array('Description', array('tag'=>'', 'escape'=>false)),
								array(array('data'=>'HtmlTag'),
									array('tag'=>'td', 'valign'=>'top', 'style'=> 'background-color:#ffffff;text-align:left')),
								array('Label', array('tag'=>'td')),
								array(array('row'=>'HtmlTag'), array('tag'=>'tr'))),
								array('pname', 'pkey', 'url', 'lead', 'description')
								);
								
		$this->addDecorators(array(
				'FormElements',
				array('HtmlTag', array('tag' => 'table','width'=>'100%','cellspacing'=>'0','border'=>'0','class'=>'pform')),
				'Form'
		));
	}
}
